home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ZED3D095.ZIP / CONSTZ.TXT next >
Text File  |  1996-01-04  |  3KB  |  98 lines

  1. In article <3nn9gp$nj0@ixnews2.ix.netcom.com> plugg@ix.netcom.com (Sandra Desmond) writes:
  2.  
  3. >Cool! Maybe we'll be able to figure out how Michael Abrash managed to
  4. >get all of Quake's divides for free!
  5.  
  6. >In any case it'll certainly help improve the signal-to-noise ratio here
  7. >;)
  8.  
  9. >Cheers,
  10.  
  11. >Mark Feldman
  12.  
  13. Hello Mr. Feldman.
  14.  
  15. I have already proposed this solution many times in this newsgroup, but I'll 
  16. reiterate as it seem to have evaded everyone's memory. My personnal opinion of 
  17. it is it's not worth it, but here goes anyhow.
  18.  
  19. Say the constant-z lines are within 45 degrees of being vertical (the 
  20. algorithm can be tweaked to work with any angle, either by using a reflection 
  21. or by really tweaking it, but I won't discuss this). For example, here are the 
  22. constant-z lines:
  23.  
  24. abcdefg
  25. abcdefg
  26. bcdefgh
  27. bcdefgh
  28. bcdefgh
  29. cdefghi
  30. cdefghi
  31. defghij
  32. defghij
  33. defghij
  34. efghijk
  35.  
  36. etc...
  37.  
  38. Now look at a horizontal scan-line. You intersect exactly one constant-z line 
  39. per pixel. The first horizontal line looks like this:
  40.  
  41. abcdefg
  42.  
  43. If we were to have a wider screen to the right, we would also have the 
  44. constant-z lines h,i,j and k. Example:
  45.  
  46. abcdefghijk
  47.  
  48. Now, calculate the real texture coordinate for all these pixels. You now know 
  49. the true texture coordinate for all pixels of all constant-z lines for the 
  50. first horizontal-line.
  51.  
  52. As you go to the second horizontal line, you can incrementally find the new 
  53. texture coordinates of these constant-z lines, them being constant-z that is.
  54.  
  55. Thus, for each horizontal line, you can incrementally calculate the new 
  56. texture coordinate of all constant-z lines.
  57.  
  58. What we do is generate the spans with a conventional horizontal scan-line 
  59. algorithm and only draw the relevant pixels (while we still possibly 
  60. incrementally calculate more than the relevant pixels).
  61.  
  62. Thus, if the polygon to draw is:
  63.    d 
  64.   cde
  65.  cdef
  66. bcdefg
  67.   defg
  68.     ghi
  69.       i
  70.  
  71. We initially need to calculate the true texture coordinate of the topmost 
  72. pixel, then for all pixels on the "d" constant-z line, the calculations can be 
  73. performed incrementally. On the second horizontal scanline, we need to 
  74. calculate the true texture coordinates for the pixel in the c and e constant-z 
  75. lines, but then we can calculate all of the texture coordinates on constant-z 
  76. lines "c", "d" and "e" incrementally. On the next horizontal scanline, we need 
  77. to calculate the true texture coordinate of the "f" scanline, but thereafter 
  78. we can calculate it incrementally. Etc...
  79.  
  80. The advantages are nearly the same as the straight constant-z polygon drawing 
  81. algorithm. The disadvantages however, are a bit different. It will not be as 
  82. fast, involving one more lookup per pixel. The algorithm is also much more 
  83. complicated and difficult to implant. However, we removed the aliasing from 
  84. the polygon's edges (e.g. the outline will be correct in the sense that it 
  85. will be exactly the same one as when generated with a horizontal scan-line 
  86. algorithm).
  87.  
  88. I know this algorithm is not discussed at all in Zed3D, but there are so many 
  89. things that need adding in Zed3D that I am not totally certain that I will be 
  90. able to add this particular one (since I am going on a 3 week trip very soon). 
  91. As a matter of fact, I'm going to copy and paste this article as is in Zed3D 
  92. now that I think of it.
  93.  
  94. Wish you the best of lucks, and may this help you.
  95.  
  96. Sebastien Loisel
  97.  
  98.